/*
Copyright (c) 2009, SSC Inc. All rights reserved.
version: 1.0
author: jaybird
*/

var Event = YAHOO.util.Event,
	Dom = YAHOO.util.Dom;
			
function creCalendarGroup(ele,target) {
				if(Dom.hasClass(ele,"dn"))Dom.removeClass(ele,"dn");
				calendar = new YAHOO.widget.CalendarGroup("",ele);
				//本地化日历显示
				 
				calendar.cfg.setProperty("MY_LABEL_YEAR_POSITION",1);
				calendar.cfg.setProperty("MY_LABEL_MONTH_POSITION",2);
				calendar.cfg.setProperty("MY_LABEL_YEAR_SUFFIX","年");
				calendar.cfg.setProperty("MY_LABEL_MONTH_SUFFIX","月");
				calendar.cfg.setProperty("MONTHS_LONG",["一","二","三","四","五","六","七","八","九","十","十一","十二"]);
				calendar.cfg.setProperty("WEEKDAYS_SHORT",["日","一","二","三","四","五","六"]);
				calendar.render();
				//选择日历后事件

				calendar.selectEvent.subscribe(function(){
					if(calendar.getSelectedDates().length > 0) {
						var selDate = calendar.getSelectedDates()[0];
					}
					Dom.get(target).value = selDate.getFullYear() + "-" + (selDate.getMonth()+1) + "-" + selDate.getDate();
					Dom.addClass(ele,"dn");
				});
				//点击日历之后隐藏
				Event.on(document,"click",function(e){
					var el = Event.getTarget(e);
					var dialogEl = Dom.get(ele);
					if(el!=dialogEl && !Dom.isAncestor(dialogEl,el) && el != Dom.get(target))
						Dom.addClass(ele,"dn");
			});	
		
}